<template>
    <el-dialog
        v-model="dialogVisibleShow"
        title="添加网址"
        width="100%"
        :before-close="handleClose"
    >
    <el-input v-model="url" placeholder="请输入网址" />
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="handleClose">取消</el-button>
                <el-button type="primary" @click="handleAddClick">
                    添加
                </el-button>
            </span>
        </template>
    </el-dialog>
</template>

<script lang="ts" setup>
import { ref,watch } from "vue";
const emits = defineEmits(['closeDialog']);
const url = ref('https://www.baidu.com')
const props = defineProps({
    dialogVisible: {
        type: Boolean,
        default: false,
    }
})
const dialogVisibleShow = ref(false);

const handleClose = () => {
    emits('closeDialog')
};
const handleAddClick = async () => {
    const result = await window.myApi.sendUrl(url.value)
    console.log(result)
}
watch(()=>props.dialogVisible,(val)=>{
    dialogVisibleShow.value = val;
},{immediate: true,})
</script>
<style scoped>
.dialog-footer button:first-child {
    margin-right: 10px;
}
</style>
